<template>
	<view>
		<view class="status_bar">
			<view style="margin-left: 3%;" @tap="goBack()"><u-icon name="arrow-leftward" size='24' /></view>
			<view style="margin-left: -50upx; font-weight: bold;" v-if="type=5"> 修改电话</view>

			<view></view>
			</u-icon>
		</view>
		<!-- <view style="display: flex;">
	 		<view style="padding: 20upx 0;"><span
	 				class="icon-title">|</span>{{type=="remark"?"修改备注后，仅自己可见":"修改电话后，仅自己可见"}}</view>
	 	</view> -->

		<view class="shop-box">
			<!-- <u--input v-model="value1" placeholder="请输入内容" height=200 border="none" clearable></u--input> -->
			<u--input v-model="remark" placeholder="请输入电话" height=200 clearable></u--input>
		</view>

		<view @click="getcommit" class="btn-box">确定</u-button></view>

	</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				startX: 0, // 触摸开始的X坐标
				endX: 0, // 触摸结束的X坐标
				threshold: 50, // 设置滑动多少距离后触发返回
				value1: '',
				value2: '',
				type: '',
				whats_up: '',
				info: '',
				remark: ''
			}
		},
		onLoad(options) {
			this.info = JSON.parse(options.groupId)
			console.log(this.info)
			// this.getDetail()
		},
		methods: {
			validatePhone() {
				const phoneRegex = /^1[3-9]\d{9}$/; // 中国大陆手机号正则
				this.isPhoneValid = phoneRegex.test(this.remark);
			},
			// 提交
			getcommit() {
				this.validatePhone();
				if (this.isPhoneValid) {
					uni.request({
						url: this.$api.baseUrl + '/api/user/change/name',
						header: {
							'content-type': 'application/json'
						},
						data: {
							"user_uid": uni.getStorageSync('user_uid'),
							"friend_user_uid": this.info.user_uid,
							"mobile_num": this.remark
						},
						method: 'POST',
						success: res => {
							console.log(res, 'res');
							// uni.hideLoading()
							if (res.data.code == 0) {
								uni.$emit('refreshList');
								uni.navigateBack({
									delta: 1
								});
							}
							console.log(this.list);
							// this.list = res.data;
						},
						fail: res => {
							console.log(res);
						}

					})
				} else {
					this.$util.toast('手机号不合法')
					return
				}
				return

			},
			goBack() {
				uni.navigateBack({
					delta: 1
				});
			},

			logout() {
				
				// uni.clearStorageSync()
				uni.MBSocketProvider.closeLocalSocket();
				uni.setStorageSync('loginInfo', {});
				uni.setStorageSync('token', '')
				uni.setStorageSync('user_uid', '')
				uni.setStorageSync('userId', '')
				uni.setStorageSync('user_level', '')
				uni.setStorageSync('nickname', '')
				uni.setStorageSync('user_avatar_file_name', '')
				uni.setStorageSync('loginInfoArr', []);
				this.toPage('/pages/login')
			},
			showEdit() {
				this.groupName = this.group.name
				this.$refs.edit.open()
			},
			cancelEdit() {
				this.$refs.edit.close()
			},


		}
	}
</script>

<style lang="scss" scoped>
	.container {
		width: 100%;
		height: 100%;
	}

	.status_bar {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-top: 50upx;
	}

	.status_bar,
	.head {
		background-color: #fff;
		height: 160upx;

		.face {
			width: 160upx;
			height: 160upx;
			border-radius: 10upx;
		}

		.info-name {
			font-size: 40upx;
			font-weight: bold;
		}

		.info-num {
			// width: 56upx;
			padding: 2upx 30upx;
			background: #f0f4f7;
			border-radius: 30upx;
			margin-top: 21upx;
		}

		.copybtns {
			color: #4457a4;
			margin-top: 21upx;
		}
	}


	.shop-box {
		width: 92%;
		height: 36%;
		margin-left: 4%;
		background-color: #f8f9fb;
		margin-top: 20upx;
		border-radius: 20upx;
		padding: 10upx 30upx;
		color: #2e2e2e;
		font-weight: 300;

		image {
			width: 70upx;
			height: 70upx;
			padding: 10upx 28upx 0upx 10upx;

		}

		::v-deep.u-textarea[data-v-81cd9d32],
		.uni-textarea-textarea {
			background-color: #f8f9fb;
		}

		::v-deep.u-input__content__clear {
			background-color: #1a76f1;
		}
	}

	.btn-box {
		width: 92%;
		margin-left: 4%;
		position: absolute;
		bottom: 80upx;
		background: #1a76f1;
		color: #fff;
		text-align: center;
		height: 80upx;
		line-height: 80upx;
		border-radius: 20upx;
	}

	.icon-title {
		color: #d54827;
		font-weight: bold;
		margin-right: 20upx;
		margin-left: 36upx;
	}
</style>